<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <!--<link rel="stylesheet" href="https://cdn.bootcss.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">-->
    <!--<script src="https://cdn.bootcss.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>-->
    <script src="javascripts/jquery-3.3.1.js"></script>
    <link rel="stylesheet" href="stylesheets/layui.css"  media="all">
    <script src="layui/layui.js" charset="utf-8"></script>
    <!--<link rel="stylesheet" href="https://heerey525.github.io/layui-v2.4.3/layui-v2.4.5/css/layui.css"  media="all">-->

    <script>/*
        $(function () {
            $('#btn').click(function (event) {
                if ($('#file').val()!=undefined){
                    var formData=new FormData();
                    formData.append('name',$('#file').val());
                    formData.append('file',$('#file')[0].files[0]);
                    //var data = $('#file').val()[0];
                    $.ajax({
                        url:'/upload',
                        type:'post',
                        data:formData,
                        cache:false,
                        processData:false,
                        contentType:false

                    }).done(function () {
                        console.log("上传成功");
                    })
                }
            })
        })
*/
    layui.use('upload', function() {
        var $ = layui.jquery
            , upload = layui.upload;
        //选完文件后不自动上传
        upload.render({
            elem: '#test8'
            , url: '/upload'
            , auto: false
            ,accept:'file'
            //,multiple: true
            , bindAction: '#test9'
            , done: function (res) {
                fileName_session=res.fileName;
                document.getElementById('fileName').innerText=fileName_session;
                window.parent.frames[1].location.reload();
            }
        });
    });
    </script>
</head>
<!--#f0f0f0-->
<body style="background-color: #f0f0f0;">
    <div class="" style="float: left;width: 200px">
        <div class="layui-card-header">绑定数据：<span id="fileName">暂无上传数据</span></div>
    </div>
        <div class="layui-card-header" style="float: left;font-size: 20px;margin-left: 600px" align="center"><b>i love you three thousand times!</b></div>
    <div class="layui-upload" style="float: right;">
        <button type="button" class="layui-btn layui-btn-primary" id="test8">选择文件</button>
        <button type="button" class="layui-btn layui-btn-normal" id="test9">开始上传</button>
    </div>
</body>
</html>